<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="<%=path%>/js/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="<%=path%>/js/themes/icon.css">
<script type="text/javascript" src="<%=path%>/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/jquery.min.js" charset="utf-8"></script>
<script type="text/javascript" src="<%=path%>/js/jquery.easyui.min.js"charset="utf-8"></script>
<script type="text/javascript" src="<%=path%>/js/locale/easyui-lang-zh_CN.js"charset="utf-8"></script>
<script type="text/javascript">
	
	$(function(){
		$(".easyui-linkbutton").click(function(){

		$("#hidettt").css("display","block");
		})
	})
	
		$(function(){
			
			$('#tt').datagrid({
				width:770,
				height:350,
				url:'<%=path%>/main/get/pros2',
				queryParams : {
      				 "cropid":<%=session.getAttribute("cropid")%>,
      			    },
				singleSelect:true,
				rownumbers:true,
			    selectOnCheck: true,
			    checkOnSelect: true,
			    fit:false, 
			    pagination : true,
		        loadMsg: '数据加载中...',
			    mode : 'remote',
			    delay : 500,
			    rownumbers:true,
			    checkbox:true,
				columns:[[
				{field:'flag',title:'选择标志',width:80,checkbox:true},
				/* {field:'credencetype',title:'凭证类别',width:100, editor:{type:'text', options:{required: true }}}, */
				/* {field:'credenceP',title:'单据类型',width:145,editor:{type:'text', options:{required: true }}}, */
				{field:'serialno',title:'流水号',width:145,editor:{type:'text', options:{required: true }}},
				{field:'date',title:'日期',width:145,editor:{type:'text', options:{required: true }}},
				{field:'id',title:'客户编码',width:145,editor:{type:'text', options:{required: true }}},
				{field:'customer',title:'客户',width:145,editor:{type:'text', options:{required: true }}},
			 /* 	{field:'credenceMc',title:'借方金额',width:140,editor:{type:'text', options:{required: true }}},
				{field:'credenceMd',title:'贷方金额',width:140,editor:{type:'text', options:{required: true }}},  */
				{field:'',tite:'',width:120,align:'center',
	                formatter:function(value,row,index){
	                         var save='<a id="btn" href="#" class="easyui-linkbutton" onclick="updateRecord()">生成凭证</a>';
	                    	/*  var s = '<a href="#" onclick="editrowb(this)">编辑</a> ';
		                     var c = '<a href="#" onclick="cancelrowb(this)">取消</a>';
		                     var e = '<a href="#" onclick="saverowb(this)">保存</a> '; */
	                         return save;
	                  
	                } 
	            }
				 ]],
			});
			
			var pager=$('#tt').datagrid('getPager');
		    pager.pagination({
			        pageSize:1,
			        pageNumber:1,
			        pageList :[5,10,20],// 可以设置每页记录条数的列表
			        beforePageText: '第',//页数文本框前显示的汉字  
		            afterPageText: '页    共 {pages} 页',  
		            displayMsg: '共 {total} 条记录'
		      });
			
	});
	/* 	function updateRecord(num) { 
			alert("aa")
			$("#hidettt").css("display","block");
			
		} */
</script>

<title>Insert title here</title>
<style>
	#d1{
		margin-top: 95px;
		text-align:center;
	}
#d2{
	margin-top: 40px;
}
#d2 table{border-right:1px solid black;border-bottom:1px solid black;} 
#d2 table td{border-left:1px solid black;border-top:1px solid black;width: 100px;
  		  height: 28px;text-align: center;} 
#d3{
	width: 770px;
	margin: 45px auto;
}
#d4{
	margin-left: 1274px;
	margin-top: 45px;
}

#s1{
	margin-left: 1486px;
}
</style>
<script type="text/javascript">
/* function updateRecord(num) { 
	alert("aa")
	$("#hidettt").show();
	
} */
var num="";
	function updateRecord(){
		
		var rows=new Array()
        rows = $('#tt').datagrid('getChecked');
	
	    for(var row in rows) {
	    
	    	var lsh = rows[row].serialno;
	    	console.log(lsh);
			 $.ajax({
		           type: "POST",
		           url:"<%=path%>/main/save/cre",
				   data : {      
					            "isno": lsh,
					            "cropid":<%=session.getAttribute("cropid")%>
					  	   
						},
							async : false,
							success : function(data) {
								var data = eval('(' + data + ')');
							    var num = data.status;
								if (num == 0) {
									num=num;
									 $.messager.alert("","填加成功"); 
							      	 //var row = $('#tt').datagrid('getSelected');
							           window.open("pzhenginfo.jsp?lsh="+lsh);
							         
							           $("#hidettt").show();
							        
							   	}

							}
						});
			 
			 }
};

</script>

</head>

<body>
	
<!-- 	  <div id="dd1">
				<span id="s1"><a id="sp" href="#" class="easyui-linkbutton" >审批</a></span>
				<span id="s2"><a id="zf" href="#" class="easyui-linkbutton" >作废</a></span> 
	  </div> -->
    	<div id="d1"><h2>生成凭证</h2></div>
       <div id="d3">
<!-- 		        <table id="cd">
		          <tr><td><a id="zj" href="#" class="easyui-linkbutton" onclick="insertLine()"/>增加</td>
		              <td><a id="sc" href="#" class="easyui-linkbutton" onclick="deleteLine()"/>删除</td></tr>
		        </table> -->

				<table id="tt">
				</table>
			<!-- 	<a id="btn" href="#" class="easyui-linkbutton" onclick="updateRecord()">生成凭证</a> -->
		</div>
<!--  aa-->
<div id="hidettt ttt" align="center" style="position: absolute;top: 0;left:0;display:none;" >
<table id="bt">
   <tr>
   <td>凭证类别：<input type="text" id="jzpz"></td>
   <td>凭证编号：<input type="text" id="pzbh"></td>
   <td>账单日期：<input type="text" id="zdrq"></td>
   <td>附单据数：<input type="text" id="djs"></td>
   </tr>
</table>

<table id="tt8"></table>
<table id="wb">
   <tr>
   <td>记账人：<input type="text" id="jzren" ></td>
   <td>审核人：<input type="text" id="shren"></td>
   <td>出纳：<input type="text" id="chuna"></td>
   <td>制单人：<input type="text" id="zdren"></td>
   </tr>
</table>
</div>
</body>
</html>